package com.lagou.java.mvcframework.pojo;

import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

/**
 * 封装handler方法相关的信息
 */
public class Handler {

    private List<String> userNames;

    public List<String> getUserNames() {
        return userNames;
    }

    public void setUserNames(List<String> userNames) {
        this.userNames = userNames;
    }

    private Object controller;

    private Method method;

    private Pattern pattern;//spring 中url是支持正则的

    private Map<String, Integer> parameterIndexMapping;//参数顺序, 是为了进行参数绑定, key是参数名, value代表第几个参数

    public Handler() {
    }

    public Handler(Object controller, Method method, Pattern pattern, List<String> userNames) {
        this.controller = controller;
        this.method = method;
        this.pattern = pattern;
        this.parameterIndexMapping = new HashMap<>();
        this.userNames = userNames;
    }

    public Object getController() {
        return controller;
    }

    public void setController(Object controller) {
        this.controller = controller;
    }

    public Method getMethod() {
        return method;
    }

    public void setMethod(Method method) {
        this.method = method;
    }

    public Pattern getPattern() {
        return pattern;
    }

    public void setPattern(Pattern pattern) {
        this.pattern = pattern;
    }

    public Map<String, Integer> getParameterIndexMapping() {
        return parameterIndexMapping;
    }

    public void setParameterIndexMapping(Map<String, Integer> parameterIndexMapping) {
        this.parameterIndexMapping = parameterIndexMapping;
    }
}
